import {Switch, Route} from "react-router-dom"

// 动态生成 Layout 组件的路由
function layoutRouter(routes, switchProps = {}) {
  return routes ? (
    <Switch {...switchProps}>
      {routes.map((route) => (
        <Route
          key={route.menuId}
          path={route.pageUrl}
          exact={route.isExact === 1}
          component={require("../views/" + route.component).default}
        ></Route>
      ))}
    </Switch>
  ) : null
}

export default layoutRouter
